package tantque;

public class Echiquier1 {

    public static final int HORS_JEU = -1;
    public static final int NB_RNG_TABLE = 12;
    public static final int NB_COL_TABLE = 10;
    public static final int DIM_ECHIQUIER = 8;
    public static final int INDEX_INITIAL = 21;
    public static final int INDEX_FINAL = 98;
    private final static int[] CASES;
    private final static Echiquier1 instance = new Echiquier1();


    static {
        CASES = new int[NB_RNG_TABLE * NB_COL_TABLE];
        for (int i = 0; i < 120; i++) {
            CASES[i] = HORS_JEU;
        }

        int valeur = 0;
        for (int index = INDEX_INITIAL; index <= INDEX_FINAL; index++) {
            if (index % NB_COL_TABLE == DIM_ECHIQUIER) {
                CASES[index] = valeur++;
                index += 2;
            } else {
                CASES[index] = valeur++;
            }
        }
    }

    private Echiquier1() {
    }

    public enum Case {

        a1, b1, c1, d1, e1, f1, g1, h1,
        a2, b2, c2, d2, e2, f2, g2, h2,
        a3, b3, c3, d3, e3, f3, g3, h3,
        a4, b4, c4, d4, e4, f4, g4, h4,
        a5, b5, c5, d5, e5, f5, g5, h5,
        a6, b6, c6, d6, e6, f6, g6, h6,
        a7, b7, c7, d7, e7, f7, g7, h7,
        a8, b8, c8, d8, e8, f8, g8, h8
       
    }

    public enum Direction {

        nord(10),
        nord_nord_est(21),
        nord_est(11),
        nord_est_est(12),
        est(1),
        sud_est_est(-8),
        sud_est(-9),
        sud_sud_est(-19),
        sud(-10),
        sud_sud_ouest(-21),
        sud_ouest(-11),
        sud_ouest_ouest(-12),
        ouest(-1),
        nord_ouest_ouest(8),
        nord_ouest(9),
        nord_nord_ouest(19);
        private int val;

        private Direction(final int val) {
            this.val = val;
        }

        public int valeur() {
            return val;
        }
    }

    public final static int valeur(final Case nom) {
        assert nom != null;
        return (nom.ordinal() / 8) * 2 + nom.ordinal() + 21;

    }

    public final static Case nom(final int index) {
        assert index >= 0;
        return Case.values()[index % 10 - 1 + 8 * (index / 10 - 2)];
    }

    public final static int[] getCASES() {
        return CASES;
    }

    public final static Echiquier1 getInstance() {
        return instance;
    }
}








